package com.learn.FunctionalInterface;

import java.util.function.Predicate;

/**
 * 断定型接口函数  Predicate  接受一个入参 返回boolean
 *
 * and  negate  or  isEqual  多个断定型接口判断  Predicate::isEqual
 *
 * 适合对数据做筛选和判断，常用于stream的filter过滤
 */
public class PredicateDemo {

    public static void main(String[] args) {
        Predicate<String> p = str -> str!=null;
        Predicate<String> p1 = x -> x.startsWith("A");

        System.out.println(p.and(p1).test("Alice"));
        System.out.println(p1.negate().test("Bob"));
        System.out.println(p.or(p1).test("Com"));
    }
}
